package com.fbty.mt.service.impl;


import java.util.List;
import java.util.Map;

import com.fbty.base.dao.MtJdbcDao;
import com.fbty.base.domain.Page;
import com.fbty.mt.dao.TabIpLogDao;
import com.fbty.mt.domain.TabIpLog;
import com.fbty.mt.service.TabIpLogService;
/**
 * 获取ip日志
 * @author thinkpad
 *
 */
public class TabIpLogServiceImpl implements TabIpLogService{
	private MtJdbcDao mtJdbcDao;
	private TabIpLogDao tabIpLogDao;
	@Override
	public void saveLog(TabIpLog tabIpLog) {
		tabIpLogDao.save(tabIpLog);
	}
	@Override
	public void deleteLog(Integer id) {
		tabIpLogDao.removeById(id);
	}
	@Override
	public Page pageLog(Integer pageNo, Integer pageSize) {
		String sql = "select tl.id,u.username,tl.buyNum,DATE_FORMAT(tl.buyTime,'%Y-%m-%d') as buydate,tl.num,tl.monthNum" +
				" from tab_log tl left join tab_user u on tl.uid=u.id order by tl.id";
		List<Map<String,Object>> list = mtJdbcDao.getJdbcTemplate().queryForList(sql);
		System.out.println(list.size());
		return new Page(list, (pageNo-1)*pageSize, list.size(), pageSize);
	}
	public MtJdbcDao getMtJdbcDao() {
		return mtJdbcDao;
	}
	public void setMtJdbcDao(MtJdbcDao mtJdbcDao) {
		this.mtJdbcDao = mtJdbcDao;
	}
	public TabIpLogDao getTabIpLogDao() {
		return tabIpLogDao;
	}
	public void setTabIpLogDao(TabIpLogDao tabIpLogDao) {
		this.tabIpLogDao = tabIpLogDao;
	}
	
}
